package com.lixinyue.array;

public class Demo02 {
    public static void main(String[] args) {
        //一、二维数组的声明和初始化
        //1.静态初始化
        int[][] arr1=new int [][]{{1,2,3},{2,3,4},{3,4,5}};
        //动态初始化
        int [][]arr2=new int[3][4];
        //动态初始化2
        int arr[][]=new int[3][];
        //正确
        int[] arr3[]=new int [][]{{1,2,3},{2,3},{5,7,8}};
        int[] arr4[]={{1,2,3},{3,4,5}};
        //二、如何调用数组的指定位置的元素

        //System.out.println(arr[1][0]);err
        arr[1]=new int[4];
        System.out.println(arr[1][0]);
        //三、获取数组的长度
        System.out.println(arr3.length);//3
        System.out.println(arr3[1].length);//2
        //四、如何遍历二维数组
        for (int i = 0; i < arr3.length ; i++) {
            for (int j = 0; j <arr3[i].length ; j++) {
                System.out.print(arr3[i][j]+"\t");
            }
            System.out.println();
        }
        //1	2	3
        //2	3
        //5	7	8
        //五、
        int[][] arr5=new int[3][4];
        System.out.println(arr5[0]);//[I@7699a589
        System.out.println(arr5);//[[I@58372a00
        System.out.println(arr[0]);//null
    }

}
